package com.wsx.seven.a;

import java.util.Arrays;

public class Main0003 {

    public static void main(String[] args) {
        int[] array = new int[]{1, 6, 3, 9, 5, 10, 7, 8};
        mpSort(array);
        System.out.println(Arrays.toString(array));
    }

    public static void mpSort(int[] array) {
        int length = array.length;
        for (int i = 0; i < length -1 ; i++) {
            for (int j = 0; j < length -1 -i ; j++) {
                if (array[j] > array[j + 1]) {
                    swap(array, j, j+1);
                }
            }
        }
    }

    private static void swap(int[] array, int i, int j) {
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
}
